/****************************************************
          File Name:8-7.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Sun 21 Dec 2014 12:11:32 PM CST
*****************************************************/

#include<iostream>
using namespace std;

template<class T>
T show(T arr[], int n)
{
    T tmp = arr[0];
    for(int i = 1; i < n; i++)
        tmp += arr[i];

    return tmp;
}

template<class T>
T show(T * arr[], int n)
{
    T tmp = *arr[0];
    for(int i = 1; i < n; i++)
        tmp += *arr[i];

    return tmp;
}

struct debts
{
    char name[50];
    double amount;
};

int main()
{
    int things[6] {13, 31, 103, 301, 310, 130};
    debts mr_E[3] =
    {
        {"Ima Wolfe", 2400.0},
        {"Yra Foxe", 1300.0},
        {"Iby Stout", 1800.0}
    };

    double *pd[3];

    for(int i =0; i < 3; i++)
        pd[i] = &mr_E[i].amount;

    cout << "Listing mr_E's counts of things:\n";
    cout << show(things, 6) << endl;
    cout << "Listing mr_E's debts:\n";
    cout << show(pd, 3) << endl;

    return 0;
}
